package com.siyuanren.gcocp.task;

import cn.hutool.core.date.DateUtil;
import com.siyuanren.gcocp.service.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author guwr
 * @date 2018/5/21
 */
@Component
@Slf4j
public class WxTask {
    public static int Time_7 = 7;

    @Autowired
    private TaskService taskService;

    /**
     * 上课提醒,早上7点
     */
    @Scheduled(cron = "0 0 7 * * ?")
    public void studyMorningRemind() {
        taskService.studyMorningRemind();
    }
    /**
     * 上课提醒,晚上7点
     */
    @Scheduled(cron = "0 0 19 * * ?")
    public void studyEveningRemind() {
        taskService.studyMorningRemind();
    }

    /**
     * 模板消息,5点
     */
    @Scheduled(cron = "0 0 5 * * ?")
    public void send5TemplateMsg() {
        taskService.sendTemplateMsg(5);
    }
    /**
     * 模板消息,7
     */
    @Scheduled(cron = "0 0 7 * * ?")
    public void send7TemplateMsg() {
        taskService.sendTemplateMsg(7);
    }
    /**
     * 模板消息,19点
     */
    @Scheduled(cron = "0 0 19 * * ?")
    public void send19TemplateMsg() {
        taskService.sendTemplateMsg(19);
    }
    @Scheduled(cron = "0 0 20 * * ?")
    public void send20TemplateMsg() {
        taskService.sendTemplateMsg(20);
    }

//    @Scheduled(cron = "0/5 * * * * ?")
//    public void sendTempte() {
//        System.out.println("test timer:" + DateUtil.formatDateTime(new Date()));
//        taskService.sendTemplateMsg(7);
//    }
}
